Buffer "eats" newlines

Dear folks,

I have a code like this:



void getModifications(Skip sData) {

Buffer bSource = create
Buffer bTarget = create
Buffer bResult = create
bSource = ""
bTarget = "New"
diff(bResult, bSource, bTarget, "\\cf1\\strike ", "\\cf3\\ul ")
put(sData, 1, stringOf bResult)

bSource = "Delete"
bTarget = ""
diff(bResult, bSource, bTarget, "\\cf1\\strike ", "\\cf3\\ul ")
put(sData, 2, stringOf bResult)

bSource = "Before"
bTarget = "After"
diff(bResult, bSource, bTarget, "\\cf1\\strike ", "\\cf3\\ul ")
put(sData, 3, stringOf bResult)

delete bSource
delete bTarget
delete bResult
}
DB db
DBE textbox

Skip sData = create
Buffer sReport = create
string str
getModifications sData

db = create "Report"
textbox = richText(db, "Report", "", 400, 100, false)

sReport = ""

sReport = "{\\b Report}" "\n\n"

for str in sData do {
sReport = sReport str "\n"
}

realize db
useRTFColour(textbox, true)

set(textbox, tempStringOf sReport)
show db

delete sData
delete sReport



When I execute this program, I get the following output:

NewDeleteBeforeAfter

instead of:

New
Delete
BeforeAfter

I think in some moment the buffer sReport is "eating" the newlines.
I couldn't find any help about "tempStringOf" function in "DXL Reference Manual". It is just used as part of an example.

Can you help me?

Thanking you in advance,
Ilma Orellana.
Ilma_Orellana - Tue May 10 11:30:50 EDT 2011

Re: Buffer "eats" newlines
llandale - Tue May 10 11:59:35 EDT 2011

Rich text new lines look like "\par ". Use this line instead:

sReport = sReport str "\\par "

  • Louie

Tsk tsk tsk, your use of buffer sReport is hopeless. Change it to this:
sReport += str
sReport += "\\par "

That is, add the strings to the buffer. As it is you are extracting the string and concatenating it which pretty much eliminates the use of the buffer.

Re: Buffer "eats" newlines
Ilma_Orellana - Fri May 13 08:33:13 EDT 2011

llandale - Tue May 10 11:59:35 EDT 2011
Rich text new lines look like "\par ". Use this line instead:

sReport = sReport str "\\par "

  • Louie

Tsk tsk tsk, your use of buffer sReport is hopeless. Change it to this:
sReport += str
sReport += "\\par "

That is, add the strings to the buffer. As it is you are extracting the string and concatenating it which pretty much eliminates the use of the buffer.

Dear Louie,

Thank you very much for your advices, now my program works properly.

Ilma.